package com.atguigu.config;

import com.atguigu.bean.Person;
import com.atguigu.service.BookService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

//配置类==配置文件
@Configuration  //告诉spring这是一个配置类
@ComponentScan(value = "com.atguigu",includeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class}),
        @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,classes = {BookService.class}),
        @ComponentScan.Filter(type=FilterType.CUSTOM,classes = {MyTypeFilter.class})
},useDefaultFilters = false)
//@ComponentScan value
// excludeFilters =Filter[] ;指定扫描的时候按照什么规则排除哪些组件
//includeFilters =Filter[]  ;指定扫描的时候只需要包含哪些组件
//useDefaultFilters = false 关闭默认的过滤规则,这样includeFilters才能生效
//FilterType.ANNOTATION 按照注解
//FilterType.ASSIGNABLE_TYPE  按照给定的类型
//FilterType.ASPECT //使用ASPECTJ表达式
// FilterType.ASSIGNABLE_TYPE 使用正则指定
//FilterType.CUSTOM  使用自定义规则

public class MainConfig {

    @Bean("person1") //给容器中注册一个Bean;类型为返回值的类型,id默认是用方法名
    public Person person(){

        return new Person("lisi",20);

    }
}
